// pages/mine/mine.js
const app = getApp();

Page({
  data: {
    userInfo: {},
    rainbowCode: '',
    balance: 0
  },

  onLoad() {
    this.setData({
      userInfo: app.globalData.userInfo,
      rainbowCode: app.globalData.rainbowCode,
      balance: app.globalData.balance
    });
  },

  withdraw() {
    if (this.data.balance < 51.8) {
      wx.showToast({ title: '余额未达提现门槛', icon: 'none' });
      return;
    }
    // 调用云函数申请提现
    wx.cloud.callFunction({
      name: 'processWithdraw',
      data: { amount: this.data.balance }
    }).then(res => {
      wx.showToast({ title: '提现申请成功', icon: 'success' });
    });
  }
})